﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CourseArraging.Common;
using Stone.DataContracts; 

namespace CourseArraging.Frm.jcxx
{
    /// <summary>
    /// 版权所有
    /// 石世特@温州医学院 sst330381@gmail.com
    /// </summary> 
    public partial class FrmJcxxSchool : FrmToolbarBase
    {
        #region 字段属性
        protected static FrmJcxxSchool instance;
        private BasicService.BasicServiceClient basicDao = new BasicService.BasicServiceClient();
        #endregion

        #region 构造器
        public  FrmJcxxSchool()
        {
            InitializeComponent();
            this.dataGridView1.CellDoubleClick += new DataGridViewCellEventHandler(dataGridView1_CellDoubleClick);
            showData();
        }
        public static FrmJcxxSchool GetInstance()
        {
            if (instance == null || instance.IsDisposed)
            {
                instance = new FrmJcxxSchool();
                instance.MdiParent = GlobalVar.frmMain;
            }
            instance.BringToFront();
            return instance;
        }
        #endregion

        #region 事件

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            tsb_save_fun();
        }

        void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0) return;
            FrmInfoSchool frm = new FrmInfoSchool(new DepEntity() {
                dep_info_id = int.Parse(dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString()),
                dep_info_name = dataGridView1.Rows[e.RowIndex].Cells["分校"].Value.ToString(),
                dep_info_address = dataGridView1.Rows[e.RowIndex].Cells["地址"].Value.ToString(),
                dep_info_phone = dataGridView1.Rows[e.RowIndex].Cells["电话"].Value.ToString()
            });
            frm.reflist += new FrmInfoSchool.refreshlist(frm_reflist);
            frm.ShowDialog();
        }

        void frm_reflist()
        {
            showData();
        }

        #endregion

        #region 实现抽象方法

        public void showData()
        {
            this.dataGridView1.DataSource = basicDao.getDepinfo4table(0,null,null,null); 
        }

        #endregion
    }
}
